//
//  CZMaiController.swift
//  weibo123456
//
//  Created by 露露 on 16/6/6.
//  Copyright © 2016年 lulu. All rights reserved.
//

import UIKit

class CZMaiController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        // 自定义tabbar,是只读的,不能直接使用 = 进行赋值
        // KVC 进行替换

        let mainTabbar = CZMainTabbar()
        setValue(mainTabbar, forKey: "tabBar")
        
               
//    首页
        let home = CZHomeViewController()
        self.abbChilbVC(home, title: "首页", imageName: "tabbar_home")
        
        let meessare = CZMessareViewController()
        self.abbChilbVC(meessare, title: "消息", imageName: "tabbar_message_center")
        
        let discovery = CZDiscoveryViewController()
        self.abbChilbVC(discovery, title: "发现", imageName: "tabbar_discover")
        
        let profile = CZProfileViewController()
        self.abbChilbVC(profile, title: "我", imageName: "tabbar_profile")
//        设置文字的颜色
        self.tabBar.tintColor=UIColor.orangeColor()
    
    }

    /// controller: 控制器
    /// title: 控制器显示的标题
    /// imageName: 在tabbar上面显示的图片名称
    func abbChilbVC (controller:UIViewController,title:String,imageName:String){

    // 包装控制器 导航
    self.addChildViewController(UINavigationController(rootViewController: controller))
    //设置title
    controller.title = title
    // 设置图片
         controller.tabBarItem.image=UIImage(named: imageName)

    // 设置高亮图片
        let highLightedName = imageName + "_highlighted"
//        // 设置图片,不需要系统来渲染颜色
        controller.tabBarItem.selectedImage = UIImage(named: highLightedName)?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
        


}

}
